﻿Imports System.IO
Imports System.Text
Imports MpqReader
Class frmMPQImport
    Public Structure FileListEntry
        Dim Archive As String
        Dim Path As String
        Dim Size As Integer
    End Structure
    Public FileList As New System.Collections.Generic.Dictionary(Of String, FileListEntry)
    Public Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Dim MyMPQImport As New MPQImport
        My.Settings.Import = txtLoad.Text
        MyMPQImport.PopulateFileList(My.Settings.Import)
        For Each a As MPQImport.FileListEntry In MyMPQImport.FileList.Values
            If a.Path.Contains(".m2") Then
                If a.Path.ToLower.StartsWith("character\") Then
                    frmMain.tvModels.Nodes(3).Nodes(0).Nodes.Add(a.Path)
                ElseIf a.Path.ToLower.StartsWith("creature\") Then
                    frmMain.tvModels.Nodes(3).Nodes(1).Nodes.Add(a.Path)
                ElseIf a.Path.ToLower.StartsWith("item\") Then
                    frmMain.tvModels.Nodes(3).Nodes(2).Nodes.Add(a.Path)
                End If
            End If
        Next
        Me.Close()
    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.Close()
    End Sub

    Private Sub frmMPQImport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim RegKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Blizzard Entertainment\World of Warcraft")
        txtLoad.Text = RegKey.GetValue("InstallPath") + "Data\"
    End Sub
End Class
